package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.archive;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author liwei
 * 文件中心，文件信息表
 */
@Data
@Entity
@Table(name = "t_archive_file_info")
@org.hibernate.annotations.Table(appliesTo = "t_archive_file_info", comment = "文件信息表")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ArchiveFileInfo implements Serializable {
    private static final long serialVersionUID = 5655332127691207810L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "file_id", columnDefinition = "int(20) comment '目录ID'")
    private Integer fileId;

    @ApiModelProperty(value = "文件名称")
    @Column(name = "file_name", columnDefinition = "varchar(1024) COMMENT '文件名称'")
    private String fileName;

    @ApiModelProperty(value = "文件路径")
    @Column(name = "file_path", columnDefinition = "varchar(1024) COMMENT '文件路径'")
    private String filePath;

    @ApiModelProperty(value = "文件md5校验码")
    @Column(name = "checksum", columnDefinition = "varchar(1024) COMMENT '文件md5校验码'")
    private String checksum;

    @Column(name = "group_doc_id", columnDefinition = "int(20) comment '文件组id'")
    private Integer groupDocId;

    @Column(name = "doc_id", columnDefinition = "int(20) comment '上传文件的id'")
    private Integer docId;

    @ApiModelProperty(value = "文件来源类别")
    @Column(name = "file_source_type", columnDefinition = "varchar(20) COMMENT '文件来源类别,1用户上传 2系统传输'")
    protected String fileSourceType;

    @ApiModelProperty(value = "文件来源id")
    @Column(name = "file_source_id", columnDefinition = "varchar(60) COMMENT '文件来源id'")
    protected String fileSourceId;

    @ApiModelProperty(value = "创建人ID")
    @Column(name = "create_operator", columnDefinition = "varchar(20) COMMENT '创建人ID'")
    protected String createOperator;

    @ApiModelProperty(value = "创建人姓名")
    @Column(name = "create_operator_name", columnDefinition = "varchar(20) COMMENT '创建人姓名'")
    protected String createOperatorName;

    @ApiModelProperty(value = "操作人员ID")
    @Column(name = "op_operator", columnDefinition = "varchar(20) COMMENT '操作人员ID'")
    protected String opOperator;

    @ApiModelProperty(value = "操作人员姓名")
    @Column(name = "op_operator_name", columnDefinition = "varchar(20) COMMENT '操作人员姓名'")
    protected String opOperatorName;

    @ApiModelProperty(value = "备注")
    @Column(name = "memo", columnDefinition = "varchar(255) COMMENT '备注'")
    private String memo;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间")
    @Column(name = "op_time", columnDefinition = "datetime comment '更新时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime opTime;

    @Column(name = "delete_flag", columnDefinition = "int(2) comment '手动删除标记 0未删除  1已删除 2已归档'")
    private Integer deleteFlag;

}
